<html>
<head><meta charset="utf-8"><title>Hover actions · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html">Hover actions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198442711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198442711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198442711">(May 22 2020 at 13:47)</a>:</h4>
<p>Hi,</p>
<p>I'd like to discuss a possible UX improvement, called it <code>hover actions</code> :)<br>
Two screencasts to demonstrate the idea:</p>
<p><a href="/user_uploads/4715/iSVs16yQag9Fu1kbgFMezsJB/hover_actions_run.gif">hover_actions_run.gif</a><br>
The first one is the Run|Debug lens alternative. Personally I do not like CodeLens and prefer to turn them off. Though sometimes it's handy to run a test with a single mouse click.</p>
<div class="message_inline_image"><a href="/user_uploads/4715/iSVs16yQag9Fu1kbgFMezsJB/hover_actions_run.gif" title="hover_actions_run.gif"><img src="/user_uploads/4715/iSVs16yQag9Fu1kbgFMezsJB/hover_actions_run.gif"></a></div><p>And while implementing this it has dawned upon me that such <code>hover actions</code> might be super useful for inlay hints:<br>
<a href="/user_uploads/4715/fOsTdrNpyoRorvExBrIBEZrG/hover_actions_goto.gif">hover_actions_goto.gif</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/fOsTdrNpyoRorvExBrIBEZrG/hover_actions_goto.gif" title="hover_actions_goto.gif"><img src="/user_uploads/4715/fOsTdrNpyoRorvExBrIBEZrG/hover_actions_goto.gif"></a></div><p>vscode has <code>Go to Type Definition</code> command, but it is almost useless for generics. In a hover it is possible to select a particular type.</p>
<p>What do you think?</p>



<a name="198442862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198442862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198442862">(May 22 2020 at 13:49)</a>:</h4>
<p>The best part is that everything is done on the server side, and it should work with all clients out of the box.</p>
<p>Well, not in the real world :) It depends on how a client renderers markdown. It should support command links:<br>
<code>[title](command:${command.id}?${commandArguments} "hint")</code></p>



<a name="198445814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198445814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pksunkara <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198445814">(May 22 2020 at 14:12)</a>:</h4>
<p>Love the second hover. I always keep trying to jump to definitions to using the variables which is pretty lengthy sometimes</p>



<a name="198452329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198452329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198452329">(May 22 2020 at 15:07)</a>:</h4>
<p>One other idea: would it be possible to have control+click on the inlay hint trigger go to definition?</p>



<a name="198455608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198455608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198455608">(May 22 2020 at 15:35)</a>:</h4>
<p>Afaik, it is impossible. There is not way to check a key state in vscode.</p>



<a name="198458579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198458579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198458579">(May 22 2020 at 15:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125131">detrumi</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Hover.20actions/near/198452329">said</a>:</p>
<blockquote>
<p>One other idea: would it be possible to have control+click on the inlay hint trigger go to definition?</p>
</blockquote>
<p>I think we could do that if we supported commands returned from inlay hints.</p>



<a name="198458914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198458914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198458914">(May 22 2020 at 16:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="298653">vsrs</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Hover.20actions/near/198442862">said</a>:</p>
<blockquote>
<p>The best part is that everything is done on the server side, and it should work with all clients out of the box.</p>
<p>Well, not in the real world :) It depends on how a client renderers markdown. It should support command links:<br>
<code>[title](command:${command.id}?${commandArguments} "hint")</code></p>
</blockquote>
<p>vscode supports custom markdown renderers so I think that could work?</p>



<a name="198466904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198466904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198466904">(May 22 2020 at 17:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203366">Jeremy Kolb</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Hover.20actions/near/198458914">said</a>:</p>
<blockquote>
<p>vscode supports custom markdown renderers so I think that could work?</p>
</blockquote>
<p>I'm talking about other editors.</p>
<p>The gifs are recorded in vscode. The implementation needs some polishing, but already works :) I'm just wondering if someone else will like it.</p>



<a name="198475473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198475473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198475473">(May 22 2020 at 18:12)</a>:</h4>
<p>Right... my suggestion only applies to vscode</p>



<a name="198475567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/198475567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#198475567">(May 22 2020 at 18:13)</a>:</h4>
<p>I completely missed that this is something that works. I thought you had mocked it up. I like both of those</p>



<a name="199010314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199010314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199010314">(May 28 2020 at 11:37)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> Did you have a chance to look at this? I'd like to add at least Run Debug actions.</p>



<a name="199010439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199010439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199010439">(May 28 2020 at 11:38)</a>:</h4>
<p>Yes, I like this!</p>



<a name="199010475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199010475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199010475">(May 28 2020 at 11:38)</a>:</h4>
<p>I imagine there should be some amount of protocl-level design here, but that's just some work that needs to be done</p>



<a name="199010519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199010519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199010519">(May 28 2020 at 11:40)</a>:</h4>
<p>Not at all :) It is pure markdown generated on the server side.</p>



<a name="199010591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199010591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199010591">(May 28 2020 at 11:40)</a>:</h4>
<p>Nice!</p>



<a name="199010615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199010615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199010615">(May 28 2020 at 11:41)</a>:</h4>
<p>(as a general cleanp refactoring, we might want to introduce <code>struct Markdown(String)</code> type during this work)</p>



<a name="199011016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199011016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199011016">(May 28 2020 at 11:46)</a>:</h4>
<p>with something like add_section, add_link, etc?</p>



<a name="199011045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199011045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199011045">(May 28 2020 at 11:47)</a>:</h4>
<p>I don't think we need to go as far as providing a type-safe builder, the main benefit I see is that <em>consumers</em> see if it is a String or a Markdown content or what not</p>



<a name="199011092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199011092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199011092">(May 28 2020 at 11:47)</a>:</h4>
<p>ok</p>



<a name="199017584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199017584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199017584">(May 28 2020 at 12:53)</a>:</h4>
<p>Newtypes are actually very nice to encode any kind of invariants/subsets/brending (attaching new meaning) like <code>RelativePathBuf(PathBuf)</code>, <code>NonZeroU32(u32)</code>, <code>ValidRustSourceCode(String)</code>,  <code>NonEmptyString(String)</code>, <code>IsValid(bool)</code></p>



<a name="199024155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199024155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199024155">(May 28 2020 at 13:47)</a>:</h4>
<p>I'm aware of the newtype idiom :) Just wanted to clarify if I got the idea right (nope, it turns out to be much simpler)</p>



<a name="199035032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199035032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199035032">(May 28 2020 at 15:06)</a>:</h4>
<p>We just need to keep in mind that some clients don't support markdown but that's probably not a big deal and maybe irrelevant here (I haven't looked)</p>



<a name="199138466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Hover%20actions/near/199138466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vsrs <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Hover.20actions.html#199138466">(May 29 2020 at 10:52)</a>:</h4>
<p>Of course. By default, the server does not add any hover actions. Only if the client explicitly sets in the initializationOptions that he supports them.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>